<!--
 * @Author: your name
 * @Date: 2020-10-13 09:11:50
 * @LastEditTime: 2020-10-14 15:33:24
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \nuxt-iview\pages\index.vue
-->
<template>
  <div class="">
    <Navbar />
    <Swiper />
  </div>
</template>

<script>
import Navbar from '~/components/common/Navbar'
import Swiper from '~/components/common/Swiper'
import { mapState } from 'vuex';
import { setLanguage } from '~/api/public'

export default {
  // async asyncData ({ $axios }) {
  //   const result = await $axios.get("http://localhost:8000/posts")
    // context
    // {$axios, store}
    // ErrorHandle($axios, redirect)
    // console.log('$axios :>> ', $axios);
    // console.log('store :>> ', store);
    // console.log('context :>> ', context);
    // return {
    //   posts: result.data
      // userAgent: (req ? req.headers['user-gent']:(typeof navigator !== 'undefined' ? navigator.userAgent: 'No user Agent'))
    // }
  // },
  // asyncData: ({ req }) => {
  //   return {
  //     userAgent: req
  //     ? req.headers['user-agent']
  //     : typeof navigator !== 'undefined'
  //     ? navigator.userAgent
  //     : 'No user agent (generated)'
  //   }
  // },
  data () {
    return {
      username: '',
      password: '',
      code: '',
      sid: '',
    }
  },
  computed: {
    ...mapState({
      locale: state => state.locale
    })
  },
  methods: {
    login () {
      this.$auth.loginWith('local', {
        data: {
          username: this.username,
          password: this.password,
          code: this.code,
          sid: this.sid
        }
      })
    },
    chooseLanguage(language) {
      this.$store.commit('SET_LANGUAGE', language);
      this.$i18n.locale = language;
      setLanguage({
        'language': language
      }).then(res => {
        if (res.code === 200) {
          console.log('msg', res.msg)
        }
      })
    },
  },
  components: {
    Navbar,
    Swiper
  }
}
</script>

<style>
.container {
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

</style>
